
	//弹框js
	var popup = function(parame){
		var _self = this;
		_self.parame = $.extend({}, popup.parame, parame)
	};
	//配置参数
    popup.parame = {
        width: '582', //弹层的宽度
        height: '362', //弹层的高度
        content: '', //弹层的内容
        hasMask: false,  //是否显示遮罩层
		poptype:'', //弹框类型
		enter: '', //弹框页面的效果
		leave:'' //页面离开效果
    }; 
	popup.prototype = {
		init:function(){
			var _self = this;
		},
		//创造弹窗内容
		create:function(){
			var _self = this,
			    body = $('body'),
			    popupHtml = [],
			    width = _self.parame.width,   //弹框的宽度
			    height = _self.parame.height,   //弹框的高度
		  	    title =  _self.parame.title,   //弹框的标题
			    content = _self.parame.content,    //弹层的内容
				hasMask = _self.parame.hasMask,    //是否显示遮罩层
				poptype = _self.parame.poptype,    //选择弹框类型	
				marginWidth = - width / 2;		
						 
			// 添加弹框默认内容   
			//自定义弹窗          
			popupHtml[0] = '<div class="pop-box" id="pop_box" style="display:none;margin-left:' 
						 + marginWidth
						 + 'px;top:50%;left:50%;margin-top:-1px;width:'
						 + width
						 + 'px;height:0px;"><div class="pop-close" id="pop_close"></div>'
						 + content //插入新的节点
						 + '</div>';	
						 					 
			//poptype1
			popupHtml[1] = '<div class="pop-box pop-Bgbox" id="pop_box" style="display:none;margin-left:' 
						 + marginWidth
						 + 'px;top:50%;left:50%;margin-top:-1px;width:'
						 + width
						 + 'px;height:0px;"><div class="pop-close" id="pop_close"></div>'
						 + '<div class="pop-content"><h5>' 
						 + 'Oh snap!'
						 + '</h5><p>' 
						 + '你确定要永久删除此条结算纪录吗？'
						 + '</p></div><div class="btn-box"><a class="btn-confirm" id="pop_btn_confirm">'
						 + '确定'
						 + '</a></div></div>';
						 
			//poptype2
			popupHtml[2] = '<div class="pop-box pop-Bgbox pop-Bgbox2" id="pop_box" style="display:none;margin-left:' 
						 + marginWidth
						 + 'px;top:50%;left:50%;margin-top:-1px;width:'
						 + width
						 + 'px;height:0px;"><div class="pop-close" id="pop_close"></div>'
						 + '<div class="pop-content"><h5>' 
						 + 'Alert!'
						 + '</h5><p>' 
						 + '此页面将要访问您的个人信息，确定浏览吗？'
						 + '</p></div><div class="btn-box"><a class="btn-continue" id="pop_btn_continue">'
						 + '继续浏览'
						 + '</a></div></div>';
						 
			//poptype3
			popupHtml[3] = '<div class="pop-box pop-Bgbox pop-Bgbox3" id="pop_box" style="display:none;margin-left:' 
						 + marginWidth
						 + 'px;top:50%;left:50%;margin-top:-1px;width:'
						 + width
						 + 'px;height:0px;"><div class="pop-close" id="pop_close"></div>'
						 + '<div class="pop-content"><h5>' 
						 + 'Alert!'
						 + '</h5><p>' 
						 + '此页面将要访问您的个人信息，确定浏览吗？'
						 + '</p></div><div class="btn-box"><a class="btn-continue" id="pop_btn_continue">'
						 + '继续浏览'
						 + '</a></div></div>';
						 
			//poptype4
			popupHtml[4] = '<div class="pop-box pop-Bgbox pop-Bgbox4" id="pop_box" style="display:none;margin-left:' 
						 + marginWidth
						 + 'px;top:50%;left:50%;margin-top:-1px;width:'
						 + width
						 + 'px;height:0px;"><div class="pop-close" id="pop_close"></div>'
						 + '<div class="pop-content"><h5>' 
						 + 'Oh snap!'
						 + '</h5><p>' 
						 + '你确定要永久删除此条结算纪录吗？'
						 + '</p></div><div class="btn-box"><a class="btn-confirm" id="pop_btn_continue">'
						 + '确定'
						 + '</a></div></div>';
						 
			// 判断弹出款类型，选择弹框内容
			if(!content == ''){
				body.append(popupHtml[0]);
			}else{ 	
				if(poptype == '1'){
					body.append(popupHtml[1]);
				};
				if(poptype == '2'){
					body.append(popupHtml[2]);
				};
				if(poptype == '3'){
					body.append(popupHtml[3]);
				};
				if(poptype == '4'){
					body.append(popupHtml[4]);
				};
			}
			
			//判断是否给弹框遮罩
			if(hasMask){
				popupHtml[5] = '<div class="pop-mask" id="pop_mask"></div>';
				body.append(popupHtml[5]);
			};
		
			//页面进入效果
			_self.enter();
			
			//关闭弹窗效果
			$('#pop_close').click(function(){
				if(_self.parame.leave=='spreadOut'){
				    _self.spreadOut();
				}
				if(_self.parame.leave==''){
				    _self.closeRemove();
				}
			});
						
			//确定按钮函数
			$('#pop_btn_confirm').click(function(){
				_self.btnConfirm();
			});
			
			//取消按钮函数
			$('#pop_btn_continue').click(function(){
				_self.btnContinue();
			});
			
			//添加窗口resize时调整对话框位置,对话框始终保持居中
        	$(window).resize(function(){      
				var marginWidth = - width/2 + "px"; 
				var marginHeight = - height/2 + "px";  
				$("#pop_box").css({"marginLeft":marginWidth,"marginTop":marginHeight,"top":"50%","left":"50%"});
        	});
		},
		
		//点击关闭时,默认关闭函数方法
		closeRemove: function (){
            var _self = this;
            $('#pop_box,#pop_mask').remove();//remove() 方法移除被选元素，包括所有文本和子节点。
        },
		
		//点击确定按钮时，默认确定按钮函数方法
		btnConfirm:function(){
			var _self = this;
            $('#pop_box,#pop_mask').remove();		
		},
		
		//点击继续浏览按钮时，默认继续浏览函数方法
		btnContinue:function(){
			var _self = this;
            $('#pop_box,#pop_mask').remove();		
		},
		
		//进入移出效果
		enter:function(){
			var _self = this; 
			if(_self.parame.enter=='spreadIn'){
				_self.spreadIn();
			}
			if(_self.parame.enter==''){
				_self.show();
			}
		},
		
		//弹窗进入效果--展开
		spreadIn:function(){
			var _self = this;
			var width = _self.parame.width; //弹框的宽度
			var marginWidth = - width/2 + "px"; 
			var height = _self.parame.height; //弹框的宽度
			var marginHeight = - height/2 + "px";
			var mheight = height +"px";
			$('#pop_box').show();
			$('#pop_box').animate({height:mheight,top:"50%",left:"50%",marginLeft:marginWidth,marginTop:marginHeight},300);
		},
		
		//弹窗移出效果--中间关闭
		spreadOut:function(){
			var _self = this;
			var width = _self.parame.width; //弹框的宽度
			var marginWidth = - width/2 + "px"; 
			$('#pop_mask').hide();
			$('#pop_box').animate({height:"2px",top:"50%",left:"50%",marginLeft:marginWidth,marginTop:"-1px"},100);	
			setTimeout(function () {
				$('#pop_box,#pop_mask').remove();
			}, 140);
		},
		
		//弹窗默认展示效果
		show: function(){
			var _self = this;
			var width = _self.parame.width; //弹框的宽度
			var marginWidth = - width/2 + "px"; 
			var height = _self.parame.height; //弹框的宽度
			var marginHeight = - height/2 + "px";
			var mheight = height +"px";
        	$('#pop_box').show();
			$('#pop_box').css({"height":mheight,"top":"50%","left":"50%","marginLeft":marginWidth,"marginTop":marginHeight});
        }
	}